// 查看大数据 echarts配置项
export const getBigDataOption = (val) => {
    bigDataOption.series[0].data[0].value = val
    return bigDataOption
};
const bigDataOption = {
    series: [{
        type: 'gauge',
        startAngle: 180,
        endAngle: 0,
        center: ['50%', '75%'],
        radius: '90%',
        min: 1,
        max: 0,
        splitNumber: 10,
        axisLine: {
            lineStyle: {
                width: 20,
                color: [
                    [0.2, '#74d042'],
                    [0.4, '#3bcccc'],
                    [0.6, '#41abfc'],
                    [0.8, '#ffab46'],
                    [1, '#f84a3c'],
                ]
            }
        },
        pointer: {
            show: false,
        },
        axisTick: {
            show: false
        },
        splitLine: {
            show: false
        },
        axisLabel: {
            color: '#464646',
            fontSize: 18,
            distance: -50,
            rotate: 0,
            formatter: function(value) {
                if (value === 0.9) {
                    return 'A';
                } else if (value === 0.7) {
                    return 'B';
                } else if (value === 0.5) {
                    return 'C';
                } else if (value === 0.3) {
                    return 'D';
                } else if (value === 0.1) {
                    return 'E';
                }
                return '';
            }
        },
        title: {
            offsetCenter: [0, 0],
            fontSize: 12
        },
        detail: {
            fontSize: 28,
            offsetCenter: [0, '-25%'],
            valueAnimation: false,
            formatter: function(value) {
                return numToStr(value);
            },
            color: 'inherit'
        },
        data: [{
            value: 0,
            name: '评分等级'
        }]
    }]
};
// 数值与等级转换
const staticObj = {
    'A': 0.9,
    'B': 0.7,
    'C': 0.5,
    'D': 0.3,
    'E': 0.1,
}

function numToStr(num) {
    if (num === 0) return "--"
    let str = ""
    for (const key in staticObj) {
        if (staticObj[key] === num) {
            str = key
            break;
        }
    }
    return str
}
export function strToNum(str) {
    if (str === '--') return 0
    return staticObj[str] ? staticObj[str] : 0
}